package cn.db101.fairy.crawl.runner

import cn.db101.fairy.crawl.pipeline.FairyPipeline
import cn.db101.fairy.crawl.processor.FairyProcessor
import cn.db101.fairy.crawl.processor.HzProcessor
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.CommandLineRunner
import org.springframework.stereotype.Component
import us.codecraft.webmagic.Spider

@Component
class FairyRunner: CommandLineRunner {

    @Autowired
    open lateinit var fairyPipeline: FairyPipeline

    override fun run(vararg args: String?) {

        // 格林童话
        /*for (i in 1..19) {
            Spider.create(FairyProcessor())
                .addUrl("https://story.panziye.com/page/${i}?s=%E3%80%90%E6%A0%BC%E6%9E%97%E7%AB%A5%E8%AF%9D%E3%80%91")
                .addPipeline(fairyPipeline)
                .run()
        }*/

        // 安徒生童话
        /*for(i in 1 .. 16) {

            Spider.create(FairyProcessor(1))
                .addUrl("https://story.panziye.com/page/${i}?s=%E5%AE%89%E5%BE%92%E7%94%9F%E7%AB%A5%E8%AF%9D")
                .addPipeline(fairyPipeline)
                .run()
        }*/

        // 中国神话故事
        /*for (i in 1..2) {
            Spider.create(FairyProcessor(4))
                .addUrl("https://story.panziye.com/s/zgshenhua/page/${i}")
                .addPipeline(fairyPipeline)
                .run()
        }*/

        // 故事大全
        /*for (i in 1..25) {
            Spider.create(FairyProcessor(5))
                .addUrl("https://story.panziye.com/s/3s/page/${i}")
                .addPipeline(fairyPipeline)
                .run()
        }*/

        // 历史故事
        /*for (i in 1..2) {
            Spider.create(FairyProcessor(6))
                .addUrl("https://story.panziye.com/s/zglishi/page/${i}")
                .addPipeline(fairyPipeline)
                .run()
        }*/

        // 成语故事
        /*for (i in 1..6) {
            Spider.create(FairyProcessor(7))
                .addUrl("https://story.panziye.com/s/sizi/page/${i}")
                .addPipeline(fairyPipeline)
                .run()
        }*/

        // 中国寓言
        /*for (i in 1..10) {
            Spider.create(FairyProcessor(8))
                .addUrl("https://story.panziye.com/s/zhongguo/page/${i}")
                .addPipeline(fairyPipeline)
                .run()
        }*/

    }
}